package com.ftg.shopping.member.service;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ftg.shopping.config.LayuiPage;
import com.ftg.shopping.member.entity.sp_memberinfo;
import com.ftg.shopping.member.mapper.MemberMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MemberService {


    @Autowired
    MemberMapper membermapper;

    public LayuiPage<sp_memberinfo> list(){

        LayuiPage uid = new LayuiPage();
        uid.setData(membermapper.selectList(null));
        return uid;
    }

    public sp_memberinfo findone(int id){
        return membermapper.selectById(id);
    }

    public int savemem(sp_memberinfo m){
        return membermapper.insert(m);
    }

    public int updatemem(sp_memberinfo m){
        return membermapper.updateById(m);
    }

    public int deletemem(int id){
        return membermapper.deleteById(id);
    }

    public int deletememids(List<Integer> ids){
        return membermapper.deleteBatchIds(ids);
    }

    public LayuiPage<sp_memberinfo> page1(int page,int limit,String id){
        IPage<sp_memberinfo> ip = new Page<>(page,limit);
        QueryWrapper qw = new QueryWrapper();
        qw.like("id",id);
        membermapper.selectPage(ip,id == null || id.equals("") ? null:qw);
        LayuiPage uid = new LayuiPage(ip);

        return uid;
    }

}
